package com.gitee.wsl.doc.soup.ext

import com.fleeksoft.ksoup.nodes.Node


fun Node.contains(node: Node) = isInclusiveAncestor(this, node)

private fun isInclusiveAncestor(parent: Node, node: Node): Boolean {
    var current: Node? = node
    while (current != null) {
        if (current == parent) return true
        current = current.parent()
    }
    return false
}